#include"CloseHash.hpp"
#include"LinkHash.hpp"
void TestHashTable1()
{
	//HashTable<int, int, Hash<int>> ht;
	CloseHash<int, int> ht;

	int a[] = { 2, 12, 22, 32, 42, 52, 62 };
	for (auto e : a)
	{
		ht.Insert(make_pair(e, e));
	}

	ht.Insert(make_pair(72, 72));
	ht.Insert(make_pair(32, 32));
	ht.Insert(make_pair(-1, -1));
	ht.Insert(make_pair(-999, -999));

	Hash<int> hs;
	cout << hs(9) << endl;
	cout << hs(-9) << endl;

	cout << ht.find(12) << endl;
	ht.Erase(12);
	cout << ht.find(12) << endl;

	for (auto& Node : ht.GetTable())
	{
		if(Node.status == EXIST)
			cout << Node.kv.first << " " << Node.kv.second << endl;
	}
	
}

void TestHashTable_LinkHash()
{
	int a[] = { 4, 24, 14,7,37,27,57,67,34,14,54 };
	LinkHash<int, int> ht;
	for (auto e : a)	//只插入了10个元素,因为14冗余了不插入
	{
		ht.Insert(make_pair(e, e));
	}

	ht.Insert(make_pair(84, 84));//触发增容
	ht.erase(80);
	ht.Print();
}
int main()
{
	TestHashTable1();
    return 0;
}